package com.zj.leetcode.easy;

import java.util.ArrayList;

/**
 * @program: algorithm
 * @description: 回文数
 * 9 palindrome-number
 * @author: Zhang Bo
 * @create: 2022-01-14 17:05
 **/
public class PalindromeNumber {
    public static void main(String[] args) {
        int x = 3;
        Solution solution = new PalindromeNumber().new Solution();
        System.out.println(solution.isPalindrome(x));
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean isPalindrome(int x) {

            if (x < 0) {
                return false;
            }

            int temp = x;


            ArrayList<Integer> list = new ArrayList<>();
            while (temp >= 1) {
                int item = temp % 10;
                list.add(item);
                temp = temp / 10;
            }

            int size = list.size();
            int mid = size / 2;
            for (int i = 0; i < mid; i++) {
                if (!list.get(i).equals(list.get(size - i - 1))) {
                    return false;
                }
            }

            return true;


        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}

